var clerkData = "";
/*初始化*/
function initail_1(){
    /**
    JSON.stringify()是将JavaScript对象转换为json字符串
    JSON.parse(jsonstr)是将json字符串转换为javascript对象
    */
    $.ajax({
        url:"http://localhost/PersonManSystem/record/record/"+sessionStorage.recordsidd1+".action",
        type:"get",
        dataType:'json',
        contentType:'application/json;charset=utf-8',
        success:function(data){

            clerkData = data;
            $(data['data']).each(function(){
            document.getElementById("recordsid").value = this.recordsid;
             document.getElementById("firstinstname").value = sessionStorage.firstinstnameee1;
            document.getElementById("secondinstname").value = sessionStorage.secondinstnameee1;
            document.getElementById("thirdinstname").value = sessionStorage.thirdinstnameee1;
            document.getElementById("firstposition").value = this.posname;
            document.getElementById("secondposition").value = this.posname;
            document.getElementById("thirdposition").value = sessionStorage.thirdpositionee1;
            document.getElementById("clerkname").value = this.clerkname;
            document.getElementById("clerksex").value = this.clerksex;
            document.getElementById("email").value = this.email;
            document.getElementById("mobilephone").value = this.mobilephone;
            document.getElementById("qq").value = this.qq;
            document.getElementById("telephone").value = this.telephone;
            document.getElementById("address").value = this.address;
            document.getElementById("postcode").value = this.postcode;
            $("select[name='nationality']").find("option:selected").text(this.nationality);
            $("select[name='birthplace']").find("option:selected").text(this.birthplace);
            document.getElementById("birthday").value = this.birthday;
            $("select[name='nation']").find("option:selected").text(this.nation);
            $("select[name='faith']").find("option:selected").text(this.faith);
            $("select[name='politicalstatus']").find("option:selected").text(this.politicalstatus);
            document.getElementById("idnum").value = this.idnum;
            document.getElementById("socialsecuritynum").value = this.socialsecuritynum;
            document.getElementById("age").value = this.age;
            $("select[name='education']").find("option:selected").text(this.education);
            $("select[name='educationyears']").find("option:selected").text(this.educationyears);
            document.getElementById("major").value = this.major;
            $("select[name='salarystandardname']").find("option:selected").text(this.salarystandardname);
            document.getElementById("accountbank").value = this.accountbank;
            document.getElementById("accountid").value = this.accountid;
            document.getElementById("speciality").value = this.speciality;
            document.getElementById("hobby").value = this.hobby;
            document.getElementById("resume").value = this.resume;
            document.getElementById("familyinfo").value = this.familyinfo;
            document.getElementById("note").value = this.note;
            querySalarystandard($("#thirdposition").val());
        });
     },
        error:function(XMLHttpRequest, textStatus, errorThrown){
            alert("Error");
            alert(XMLHttpRequest.status);
            alert(XMLHttpRequest.readyState);
            alert(textStatus);
        }
    });
}



/*为页面加载点击添加事件*/
function loadBind_1() {
    /*为提交添加点击事件*/
    $("#formsubmit_1").unbind("click");
    $("#formsubmit_1").bind("click", function() {
        submitData_1();
    });
}



function submitData_1(){
    var checkername = $("input[name='checkername']").val();
    if (checkername == "") {
        checkername = sessionStorage.loginclerkname;
    }

     //js对象
    var recordInfo = {
        "recordsid"         : $("input[name='recordsid']").val(),
        "instname"          :$("input[name='thirdinstname']").val(),
        "posname"           :$("input[name='thirdposition']").val(),
        "clerkname"         : $("input[name='clerkname']").val(),
        "clerksex"          : $("input[name='clerksex']").val(),
        "email"             : $("input[name='email']").val(),
        "mobilephone"       : $("input[name='mobilephone']").val(),
        "qq"                : $("input[name='qq']").val(),
        "telephone"         : $("input[name='telephone']").val(),
        "address"           : $("input[name='address']").val(),
        "postcode"          : $("input[name='postcode']").val(),
        "nationality"       : $("select[name='nationality']").find("option:selected").text(),
        "birthplace"        : $("select[name='birthplace']").find("option:selected").text(),
        "birthday"          : $("input[name='birthday']").val(),
        "nation"            : $("select[name='nation']").find("option:selected").text(),
        "faith"             : $("select[name='faith']").find("option:selected").text(),
        "politicalstatus"   : $("select[name='politicalstatus']").find("option:selected").text(),
        "idnum"             : $("input[name='idnum']").val(),
        "socialsecuritynum" : $("input[name='socialsecuritynum']").val(),
        "age"               : $("input[name='age']").val(),
        "education"         : $("select[name='education']").find("option:selected").text(),
        "educationyears"    : $("select[name='educationyears']").find("option:selected").text(),
        "major"             : $("input[name='major']").val(),
        "accountbank"       : $("input[name='accountbank']").val(),
        "accountid"         : $("input[name='accountid']").val(),
        "checkername"       : checkername,//数据库中为updatenameid变更人编号;
        "speciality"        : $("input[name='speciality']").val(),
        "hobby"             : $("input[name='hobby']").val(),
        "resume"            : $("textarea[name='resume']").val(),
        "familyinfo"        : $("textarea[name='familyinfo']").val(),
        "note"              : $("textarea[name='note']").val()
    };
     /**
    JSON.stringify()是将JavaScript对象转换为json字符串
    JSON.parse(jsonstr)是将json字符串转换为javascript对象
    */
    $.ajax({
        url:"http://localhost/PersonManSystem/record/record/update.action",
        type:"PUT",
        dataType:'json',
        contentType:'application/json;charset=utf-8',
        data:JSON.stringify(recordInfo),
        success:function(yy){
            if (yy.msg == '成功') {
                alert("复核通过！");
                window.location='RLDJFH.htm';
            }
        },
        error:function(XMLHttpRequest, textStatus, errorThrown){
            alert("Error");
            alert(XMLHttpRequest.status);
            alert(XMLHttpRequest.readyState);
            alert(textStatus);
        }
    });
}

function querySalarystandard(posname){
    $.ajax({
        url:"http://localhost/PersonManSystem/pos/query/salarystandard/"+posname+".action",
        type:"get",
        dataType:'json',
        contentType:'application/json;charset=utf-8',
        //data:posnamevalue,
        success:function(data){
            $("input[name='salarystandardname']").val(data['data']['salarystandardname']);
        },
        error:function(XMLHttpRequest, textStatus, errorThrown){  
            alert("Error");  
            alert(XMLHttpRequest.status);  
            alert(XMLHttpRequest.readyState);  
            alert(textStatus); 
        }
    });   
}